<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>for循环案例</title>
    <script>
        //1、求1-100的和的平均数
        var sum1 = 0;
        for (var i = 1; i <= 100; i++) {
            sum1 += i;
        }
        console.log(sum1 / 100);
        //2、求1-100的所有偶数和奇数的和
        var even = 0;
        var odd = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                even += i;
            } else {
                odd += i;
            }
        }
        console.log('偶数和----->' + even);
        console.log('奇数和----->' + odd);
        //3、求1-100之间能被3整除的数字的和
        var sum3 = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 3 == 0) {
                sum3 += i;
            }
        }
        console.log('能被3整除的数字的和----->' + sum3);
    </script>
</head>

<body>

</body>

</html>